/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.imagelettericon;

import ohos.aafwk.ability.fraction.Fraction;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import ohos.app.Context;

import java.security.SecureRandom;

/**
 * BaseFraction.
 *
 * @since 2021-05-27
 */
abstract class BaseFraction extends Fraction {
    /**
     * Remarks Contacts
     */
    protected static final String[] REMARKS_CONTACTS = {"Alane Avey", "Belen Brewster", "Brandon Brochu",
        "Carli Carrol", "Della Delrio", "Esther Echavarria", "Etha Edinger", "Felipe Flecha", "Ilse Island",
        "Kecia Keltz", "Lourie Lucas", "Lucille Leachman", "Mandi Mcqueeney", "Murray Matchett", "Nadia Nero",
        "Nannie Nipp", "Ozella Otis", "Pauletta Poehler", "Roderick Rippy", "Sherril Sager", "Taneka Tenorio",
        "Treena Trentham", "Ulrike Uhlman", "Virgina Viau", "Willis Wysocki"};
    /**
     * Remarks
     */
    protected static final String[] REMARKS = {"Albania", "Australia", "Belgium", "Canada", "China", "Dominica",
        "Egypt", "Estonia", "Finland", "France", "Germany", "Honduras", "Italy", "Japan", "Madagascar",
        "Netherlands", "Norway", "Panama", "Portugal", "Romania", "Russia", "Slovakia", "Vatican", "Zimbabwe"};
    /**
     * Image Resource
     */
    protected static final int[] IMAGE_RESOURCE = new int[]{ResourceTable.Media_one, ResourceTable.Media_two,
        ResourceTable.Media_three, ResourceTable.Media_four, ResourceTable.Media_five, ResourceTable.Media_six,
        ResourceTable.Media_seven, ResourceTable.Media_eight, ResourceTable.Media_nine};

    /**
     * Colors
     */
    protected static final String[] MATERIAL_COLORS = {"#DB4437", "#E91E63", "#FF5722", "#EF6C00", "#689F38",
        "#0097A7", "#4285F4", "#039BE5", "#3F51B5", "#673AB7", "#757575"};
    /**
     * 2
     */
    protected static final int VALUE_TWO = 2;

    /**
     * 5
     */
    protected static final int VALUE_THICKNESS = 4;
    /**
     * 50
     */
    protected static final int VALUE_RADIUS = 50;
    /**
     * 66
     */
    protected static final int VALUE_FONT_SIZE = 65;
    /**
     * SecureRandom
     */
    protected SecureRandom mSecureRandom = new SecureRandom();
    /**
     * Component
     */
    protected Component mComponent;

    /**
     * Context
     */
    protected Context mContext;

    /**
     * 获取布局文件的id
     *
     * @return 布局文件的id
     */
    public abstract int getUiContent();

    /**
     * 初始化组件
     */
    public abstract void initComponent();

    @Override
    protected Component onComponentAttached(LayoutScatter scatter, ComponentContainer container, Intent intent) {
        mComponent = scatter.parse(getUiContent(), container, false);
        mContext = getFractionAbility();
        initComponent();
        return mComponent;
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
    }

    @Override
    protected void onActive() {
        super.onActive();
    }

    @Override
    protected void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    protected void onInactive() {
        super.onInactive();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }
}
